package com.library.controller;

import com.library.dao.db.JdbcAdminRepository;
import com.library.dao.db.JdbcUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import com.library.entity.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

@Controller
public class HomeController {

    @Autowired
    private JdbcAdminRepository jdbcAdminRepository;

    @Autowired
    private JdbcUserRepository jdbcUserRepository;


    /**
     * @return home
     */
    @GetMapping("/home")
    public String home(HttpSession session) {
        if(session.getAttribute("id") == null||(Boolean) session.getAttribute("isLogin") == false){
            return "redirect:/";
        }
        return "home";
    }

}
